package ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.fy.fyzf.R;
import com.fy.fyzf.base.BaseActivity;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.HousesListBean;
import com.fy.fyzf.bean.RecordBean;
import com.fy.fyzf.bean.UserInfoBean;
import com.fy.fyzf.presenter.SelfPresenter;
import com.fy.fyzf.utils.AppUtils;
import com.fy.fyzf.view.SelfInfoCallBack;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ModificationPwdActivity extends BaseActivity<SelfPresenter> implements SelfInfoCallBack {


    @BindView(R.id.et_old_pwd)
    EditText etOldPwd;
    @BindView(R.id.et_new_pwd)
    EditText etNewPwd;
    @BindView(R.id.et_sure_pwd)
    EditText etSurePwd;
    @BindView(R.id.tv_save)
    TextView tvSave;

    @Override
    protected SelfPresenter createPresenter() {
        return new SelfPresenter(this);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_modification_pwd;
    }


    @Override
    public void initView() {
        super.initView();
        setTitleName("修改密码");
    }

    @Override
    public void initData() {
        super.initData();

    }


    @OnClick({R.id.et_sure_pwd, R.id.tv_save})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.et_sure_pwd:
                break;
            case R.id.tv_save:
                if (TextUtils.isEmpty(etOldPwd.getText().toString())) {
                    AppUtils.showToast("请输入原密码");
                    return;
                }

                if (TextUtils.isEmpty(etNewPwd.getText().toString())) {
                    AppUtils.showToast("请输入新密码");
                    return;
                }
                if (!etNewPwd.getText().toString().trim().equals(etSurePwd.getText().toString().trim())) {
                    AppUtils.showToast("新旧密码不一致");
                    return;
                }
                mPresenter.modifPwd(etOldPwd.getText().toString().trim(),etNewPwd.getText().toString().trim());
                break;
        }
    }

    @Override
    public void getSelfInfoSuccess(UserInfoBean userInfoBean) {

    }

    @Override
    public void upLoadImgSuccess(BaseData baseData) {

    }

    @Override
    public void updataSlefInfoSuccess(BaseData baseData) {

    }

    @Override
    public void getMsgCountSuccess(BaseData baseData) {

    }

    @Override
    public void changePwdSuccess(BaseData baseData) {
        AppUtils.showToast("修改成功");
        finish();
    }

    @Override
    public void getChangeMsgSuccess(List<RecordBean> list) {

    }

    @Override
    public void getMyHousingSuccess(HousesListBean housesListBean) {

    }
}